package com.gw2.gw2world.model;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;

import android.util.SparseArray;

public class WorldEvent implements Comparable<WorldEvent>, Serializable {
	private static final long serialVersionUID = 1L;
	/** World event */
	public int id;
	public int map_id=0;
	/** Translated world event name */
	public String name;
	/** Event map */
	public String map;
	/** Number of event before the main event can pop. It counts all the {@link Event.level} when this value is greater than 1 */
	public int eventCountBeforeMain=0;
	/** If the event is already done */
	public boolean done=false;
	public boolean active=false;
	public boolean enabled=true;
	/** Pre-events and chest event */
	public List<Event> subevents=new ArrayList<Event>(10);
	public List<ServerState> servers2=new ArrayList<ServerState>(3);
	/** Progression on home, guest1, guest2. */
	public int[] progression={0,0,0};
	public SparseArray<String> server_names=new SparseArray<String>();
	
	@Override
	public int compareTo(WorldEvent another) {
		if(done) return -1;
		if(isActive()) return 1;
		return 0;
	}
	public boolean isActive() {
		for(int i=0;i<3; i++) if(progression[i]>0) return true;
		return false;
	}
	public void updateProgression() {
		/*int[] level={0,0,0};
		int i;
		progression[0]=0; progression[1]=0; progression[2]=0;
		for(Event e : subevents) {
			i=server_names.indexOfKey(e.server_id);
			if(i!=-1 && (e.state.equals("Active") || e.state.equals("Preparation"))) {
				level[i]=e.level;
			}
		}
		for(Event e : subevents) {
			i=server_names.indexOfKey(e.server_id);
			if(e.depth<=level[i] || e.state.equals("Success")) progression[i]++;
			else break;
		}*/
	}
}
